/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.ValidatorForm;
/**
 *
 * @author Administrator
 */
public class AccountForm extends ActionForm {

    private String accNo;
    private String pass;
    private String repass;
    private int balance;

    /**
     * @return the accNo
     */
    public String getAccNo() {
        return accNo;
    }

    /**
     * @param accNo the accNo to set
     */
    public void setAccNo(String accNo) {
        this.accNo = accNo;
    }

    /**
     * @return the pass
     */
    public String getPass() {
        return pass;
    }

    /**
     * @param pass the pass to set
     */
    public void setPass(String pass) {
        this.pass = pass;
    }

    /**
     * @return the repass
     */
    public String getRepass() {
        return repass;
    }

    /**
     * @param repass the repass to set
     */
    public void setRepass(String repass) {
        this.repass = repass;
    }

    /**
     * @return the balance
     */
    public int getBalance() {
        return balance;
    }

    /**
     * @param balance the balance to set
     */
    public void setBalance(int balance) {
        this.balance = balance;
    }

    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getAccNo().length() < 1 || getAccNo() == null) {
            errors.add("accNo",new ActionMessage("errors.required","AccountNo"));
        }
        if (getPass().length() < 1 || getPass() == null) {
            errors.add("pass",new ActionMessage("errors.invalid","Password"));
        }
        if (getRepass().length() < 1 || !getRepass().equals(getPass())) {
            errors.add("repass",new ActionMessage("errors.invalid","Repass"));
        }
        if (getBalance() < 1 ) {
            errors.add("balance",new ActionMessage("errors.invalid","Balance"));
        }
        return errors;
    }
}
